<?php
class ParamDescription extends CActiveRecord {
	/**
	 * The followings are the available columns in table 'param_desc':
	 * @var integer $param_id
	 * @var string $param_mnemonic
	 * @var string $param_label
	 * @var string $param_type
	 * @var integer $read_only
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className= __CLASS__) {
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName() {
		return 'param_desc';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules() {
		return array (
			array (
				'param_mnemonic',
				'length',
				'max' => 10
			),
			array (
				'param_label',
				'length',
				'max' => 100
			),
			array (
				'param_mnemonic, param_label, param_type',
				'required'
			),
			array (
				'read_only',
				'numerical',
				'integerOnly' => true
			)
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations() {
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array (
			'headers' => array (
				self::HAS_MANY,
				'ParamHeader',
				'param_id',
				'order' => 'column_index'
			),
			'values' => array (
				self::HAS_MANY,
				'ParamValue',
				'parameter_id',
				'order' => 'value_row, value_column'
			)
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels() {
		return array (
			'param_id' => 'Param Id',
			'param_mnemonic' => 'Param Mnemonic',
			'param_label' => 'Param Label',
			'param_type' => 'Param Type',
			'read_only' => 'Read Only'
		);
	}

	private static $_db;

	public function getDbConnection() {
		return self::$_db;
	}

	public function setDbConnection($db) {
		self::$_db= $db;
	}

}
?>